<?php


/*
 * 交叉营销
 */

/**
 * 交叉营销
 *
 * @package system
 * @subpackage crosssale
 * 
 * @author etpasse
 * 
 */
class Handler_crosssale {
    
    
    /**
     * 设置交叉营销的酒店订单ID
     *  
     * @global object $member_info
     * @param int $order_id
     * @return boolean 
     */
    public static function setCrossSaleHotelOrderId($order_id) {
        global $member_info;
        if ($member_info->user_id) {
            $Cache_Lite = MemoryCache::getInstance();
            $Cache_key = Handler_string::generateCheckCode($member_info->user_id, 'cross_sale');
            $info = $Cache_Lite->get($Cache_key);
            $info['hotel_order_id'] = $order_id;
            $Cache_Lite->set($Cache_key, $info, 43200);
        } else {
            return FALSE;
        }
        return TRUE;
    }

    /**
     * 设置交叉营销的机票订单ID
     *  
     * @global object $member_info
     * @param int $order_id
     * @return boolean 
     */
    public static function setCrossSaleFlightOrderId($order_id) {
        global $member_info;
        if ($member_info->user_id) {
            $Cache_Lite = MemoryCache::getInstance();
//            $Cache_key = md5('cross_sale_' . $member_info->user_id);
            $Cache_key = Handler_string::generateCheckCode($member_info->user_id, 'cross_sale');
            $info = $Cache_Lite->get($Cache_key);
            $info['flight_order_id'] = $order_id;
            $Cache_Lite->set($Cache_key, $info, 43200);
        } else {
            return FALSE;
        }
        return TRUE;
    }

    /**
     * 获取交叉营销的酒店订单ID
     * 
     * @global object $member_info
     * @return  int 
     */
    public static function getCrossSaleHotelOrderId() {
        global $member_info;

        if ($member_info->user_id) {
            $Cache_Lite = MemoryCache::getInstance();
            $Cache_key = Handler_string::generateCheckCode($member_info->user_id, 'cross_sale');
            if (!$info = $Cache_Lite->get($Cache_key)) {
                return '0';
            } else {
                return $info['hotel_order_id'];
            }
        }
        return '0';
    }

    /**
     * 获取交叉营销的机票订单ID
     *  
     * @global object $member_info
     * @return  int
     */
    public static function getCrossSaleFlightOrderId() {
        global $member_info;

        if ($member_info->user_id) {
            $Cache_Lite = MemoryCache::getInstance();
            $Cache_key = Handler_string::generateCheckCode($member_info->user_id, 'cross_sale');
            if (!$info = $Cache_Lite->get($Cache_key)) {
                return '0';
            } else {
                return $info['flight_order_id'];
            }
        }
        return '0';
    }
    
}

?>
